﻿<telerik:RadWindow xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
                   xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                   xmlns:behaviors="clr-namespace:Rio.Framework.Pages.AppCode.Helpers.Behavior"
                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                   xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                   xmlns:converter="clr-namespace:Rio.Framework.Pages.AppCode.Helpers.Converter"
                   x:Name="childWindow"
                   mc:Ignorable="d"
                   x:Class="Rio.Framework.Pages.ChildWindows.AddDocumentVersionChildWindow"
                   Width="500"
                   Height="353"
                   Loaded="childWindow_Loaded"
                   KeyUp="childWindow_KeyUp"
                   xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <telerik:RadWindow.Resources>
        <converter:VersionItemToStyleConverter x:Key="VersionItemToStyleConverter" />
        <converter:MajorMinorToBooleanConverter x:Key="MajorMinorToBooleanConverter" />
        <DataTemplate x:Key="VersionItemsDataTemplate">
            <Grid>
                <TextBlock Text="{Binding FullVersion, StringFormat='- Version \{0\}'}"
                           Margin="{Binding Minor, Converter={StaticResource VersionItemToStyleConverter}, ConverterParameter=Margin}"
                           Foreground="#FF004C8D"
                           FontWeight="{Binding IsCurrentVersion, Converter={StaticResource VersionItemToStyleConverter}, ConverterParameter=Bold}"
                           FontStyle="{Binding IsCurrentVersion, Converter={StaticResource VersionItemToStyleConverter}, ConverterParameter=Italic}" />
            </Grid>
        </DataTemplate>
    </telerik:RadWindow.Resources>

    <Grid x:Name="LayoutRoot"
          Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition Height="4*" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock x:Name="VersionType"
                   TextWrapping="Wrap"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Left" />
        <StackPanel Grid.Row="1"
                    Orientation="Horizontal"
                    Margin="10,0,0,0"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Left">
            <RadioButton x:Name="MajorRadioButton"
                         GroupName="VersionTypeGroup"
                         IsChecked="{Binding IsMajor, ElementName=childWindow, Mode=TwoWay}" />
            <RadioButton x:Name="MinorRadioButton"
                         GroupName="VersionTypeGroup"
                         Margin="30,0,0,0" />
        </StackPanel>
        <TextBlock x:Name="FileTextBlock"
                   Grid.Row="2"
                   TextWrapping="Wrap"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Left" />
        <ContentControl x:Name="BrowseFileContentControl"
                        Grid.Row="4"
                        Margin="20,0,0,0"
                        VerticalAlignment="Center">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Button x:Name="BrowseButton"
                        Click="Button_Click"
                        Width="100"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        IsEnabled="{Binding IsChecked, ElementName=FilesSystemTextBlock, Mode=TwoWay}" />
                <TextBlock x:Name="selectedFilenameTextBlock"
                           Grid.Column="1"
                           TextTrimming="WordEllipsis"
                           VerticalAlignment="Center"
                           Margin="10,0,0,0"
                           HorizontalAlignment="Left" />
            </Grid>
        </ContentControl>
        <StackPanel Orientation="Horizontal"
                    Grid.Row="7"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Bottom">
            <Button x:Name="OKButton"
                    VerticalAlignment="Bottom"
                    Width="100" Command="{Binding ValidWindow, ElementName=childWindow, Mode=TwoWay}" />
            <Button x:Name="CancelButton"
                    Click="CancelButton_Click"
                    Margin="20,0,0,0"
                    VerticalAlignment="Bottom"
                    Width="100" />
        </StackPanel>
        <RadioButton x:Name="FilesSystemTextBlock"
                     HorizontalAlignment="Left"
                     Grid.Row="3"
                     Margin="10,0,0,0"
                     VerticalAlignment="Center"
                     GroupName="SourceGroup"
                     IsChecked="{Binding UseSelectedFile, ElementName=childWindow, Mode=TwoWay}">
        </RadioButton>
        <RadioButton x:Name="OldVersionTextBlock"
                     HorizontalAlignment="Left"
                     Grid.Row="5"
                     Margin="10,0,0,0"
                     VerticalAlignment="Center"
                     GroupName="SourceGroup">
        </RadioButton>
        <ContentControl x:Name="OldVersionsContentControl"
                        IsEnabled="False"
                        Grid.Row="6"
                        Margin="20,0,0,39">
            <ListBox ItemTemplate="{StaticResource VersionItemsDataTemplate}"
                     Width="{Binding ActualWidth, ElementName=OldVersionsContentControl}"
                     Height="{Binding ActualHeight, ElementName=OldVersionsContentControl}"
                     ItemsSource="{Binding Versions, ElementName=childWindow}"
                     SelectedItem="{Binding SelectedVersion, ElementName=childWindow, Mode=TwoWay}"
                     IsEnabled="{Binding IsChecked, ElementName=OldVersionTextBlock, Mode=TwoWay}" />
        </ContentControl>
        <sdk:Label Grid.Row="6"
                   Height="28"
                   HorizontalAlignment="Left"
                   Margin="24,83,0,0"
                   Name="MaxVersionLabel"
                   VerticalAlignment="Top"
                   Width="442"
                   Foreground="Red"
                   Content=" " />
    </Grid>
</telerik:RadWindow>